package configs

import (
	"github.com/go-acme/lego/v3/log"
	"github.com/micro/go-micro/v2/config"
)

var (
	CONFIG_PATH = "./conf/"
	EsConf      Elasticsearch
	DbConf      Database
)

func InitConfigs(path string) error {
	CONFIG_PATH = path
	log.Print(CONFIG_PATH)
	// 解析配置信息
	if err := config.LoadFile(CONFIG_PATH + "/conf.yaml"); err != nil {
		panic("配置文件读取失败")
	}
	// 获取es配置信息
	if err := config.Get("elasticsearch").Scan(&EsConf); err != nil {
		return err
	}
	// 获取数据库配置
	if err := config.Get("database").Scan(&DbConf); err != nil {
		return err
	}
	return err
}
